package com.tju.resource.oauth.controller.tb;

import com.tju.resource.model.TbQcOrder;
import com.tju.resource.model.TbReportOrder;
import com.tju.resource.server.TbQcOrderService;
import com.tju.resource.server.TbReportOrderService;
import com.tju.resource.server.TbStorageService;
import com.tju.resource.tool.result.Result;
import com.tju.resource.tool.tool.ClientParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 入库查询
 */
@RestController
public class TbStorageController {
    private final static String prefix = "storage/";
    @Autowired
    private TbReportOrderService tbReportOrderService;
    @Autowired
    private TbStorageService tbStorageService;
    /**
     * 查询入库
     */
    @PostMapping(prefix + "/list")
    @PreAuthorize("hasAuthority('sys:quality:storage:list')")
    public Result<Object> list(@RequestBody ClientParameters param) {
        return tbReportOrderService.selectTbReportOrder(param);
    }

    /**
     * 审核入库
     */
    @PostMapping(prefix + "/approve")
    @PreAuthorize("hasAuthority('sys:quality:storage:approve')")
    public Result<Object> list(@RequestBody TbReportOrder reportOrder) {
        return tbStorageService.approve(reportOrder);
    }
}
